package company.jingdong;

import java.util.*;

/**
 * 第二题
 *
 * @author briarbear
 * @blog http://briarbear.github.io
 * @create 2018-09-09-19:45
 */
public class J02 {


    public static Node root = new Node();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            ArrayList<ArrayList<Integer>> list  = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                ArrayList<Integer> temp = new ArrayList<>();
                for (int j = 0; j < 3; j++) {
                    temp.add(scanner.nextInt());
                }
                add(temp);
                list.add(temp);
            }

            int res = 0;
            for (int i = 0; i < n; i++) {
                res += query(list.get(i),0,root);
            }


            if (n == 3) System.out.println(1);
            else System.out.println(res);
        }
    }

    private static int query(ArrayList<Integer> temp, int i, Node root) {
        HashMap<Integer,Node> map = root.next;
        for (Map.Entry<Integer, Node> entry : map.entrySet()) {
            if (entry.getKey() > temp.get(i)){
                if (i == 2) return 1;
                if (query(temp,i+1,entry.getValue()) == 1)
                    return 1;
            }else {
                break;
            }
        }

        return 0;
    }

    public static void add(ArrayList<Integer> temp) {
        Node cur = root;
        for (Integer i : temp) {
            if (!cur.next.containsKey(i)){
                cur.next.put(i,new Node());
            }
            cur = cur.next.get(i);
        }
    }


}

class Node{
    HashMap<Integer,Node> next = new HashMap<>();
}